<!--
 * @Author: 梁 卓
 * @Version: V1.0.0
 * @Date: 2024-03-02 10:32:10
 * @LastEditors: 梁 卓
 * @LastEditTime: 2024-03-02 14:03:20
 * @FilePath: clubedit.html
 * Copyright 2024 Marvin, All Rights Reserved. 
 * 2024-03-02 10:32:10
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>新增俱乐部信息</title>
  <script src="../../scripts/boot.js" type="text/javascript"></script>
  <script src="../../demo/demo.css" type="text/javascript"></script>
  <style type="text/css">
    html, body
    {        
        padding:0;
        margin:0;
        border:0;
        height:100%;
        overflow:hidden;
    }
    .asLabel .mini-textbox-border,
    .asLabel .mini-textbox-input,
    .asLabel .mini-buttonedit-border,
    .asLabel .mini-buttonedit-input,
    .asLabel .mini-textboxlist-border
    {
        border:0;background:none;cursor:default;
    }
    .asLabel .mini-buttonedit-buttons,
    .asLabel .mini-buttonedit-button,
    .asLabel .mini-textboxlist-close
    {
        display:none;
    }
    .asLabel .mini-textboxlist-item
    {
        padding-right:8px;
    }    
    </style>
</head>
<body>
  <form id="form1" method="post">
    <input name="clubId" class="mini-hidden" />
    <fieldset style="border:solid 1px #aaa;padding:3px;">
        <legend >新增俱乐部信息</legend>
        <div style="padding:5px;">
    <table>
        <tr>
            <td align="right">俱乐部名称：</td>
            <td>    
                <input name="clubName" class="mini-textbox" required="true" />
            </td>
            <td  align="right">俱乐部负责人：</td>
            <td >
                <input name="head" class="mini-textbox" required="true"/> 
            </td>
            
        </tr>
        <tr>
            <td  align="right">创建时间：</td>
            <td >
                <input name="createTime" class="mini-datepicker" 
                 required="true" ondrawdate="onDrawDate"/>
            </td>
            <td  align="right">俱乐部类型：</td>
            <td >    
                <input name="clubType" class="mini-combobox asLabel" url="../../data/club.txt"
                 valueField="id" textField="text"  readonly="true"/>
            </td>
        </tr>   
        <tr>
            <td  align="right">余票数量：</td>
            <td >    
                <input name="remain" class="mini-textbox asLabel"
                vtype="int;range:0,500"  required="true" readonly="true"/>
            </td>
        </tr> 
        <tr>
            <td align="right">简介：</td>
            <td colspan="3">  
                <input name="remarks" class="mini-textarea asLabel" style="width:395px;" readonly="true"/>
            </td>
        </tr>         
    </table>            
        </div>
    </fieldset>
    <div style="text-align:center;padding:10px;">               
        <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>       
        <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>           
    </div>        
</form>
<script type="text/javascript">
    mini.parse();

    var form = new mini.Form("form1");
    form.setChanged(false);

//////////////////////渲染////////////////////////////////////
    function onDrawDate(e) {
        var date = e.date;
        var d = new Date();
        if (date.getTime() > d.getTime()) {
            e.allowSelect = false;
        }
    }

    /////////////主键传值//////////////////////
    function SetData(data) {
      data = mini.clone(data)
      // 发送请求
      queryClubInfoById(data.clubId)
    }


/////////////////////////////////////////////////////////////
    function SaveData() {
        var o = form.getData();
        form.validate();
        if (form.isValid() == false) {
            return;
        }
        var json = mini.encode(o);
        mini.confirm('确定要保存吗？', '提示', function (action) {
          if(action == 'ok') {
            updateClubInfo(json)
          } else {
            CloseWindow("update");
          }

        })
    }

    function onOk(e) {
        SaveData();
    }
    
    function onCancel(e) {
        CloseWindow("close");
    }

    //////////////////ajax/////////////////////////////////
    // 添加俱乐部信息接口
    function updateClubInfo(json) {
        $.ajax({
            url: "/club/clubeditaction?method=updateClubInfo",
            type: 'post',
            data: { data: json },
            cache: false,
            success: function (text) {
                mini.alert(text, '提示', function() {
                    CloseWindow("update");
                })
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
                CloseWindow();
            }
        });
    }

    // 查询俱乐部信息接口
    function queryClubInfoById(clubId) {
      $.ajax({
            url: "/club/clublistaction?method=queryClubInfoById&clubId=" + clubId,
            type: 'get',
            cache: false,
            success: function (res) {
                var o = mini.decode(res)
                form.setData(o)
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
                CloseWindow();
            }
        });
    }

    
    // 管理窗口
    function CloseWindow(action) {            
        if (action == "close" && form.isChanged()) {
          mini.confirm("数据被修改了，是否先保存？", '提示', function(ac) {
            if (ac == "ok") {
              SaveData()
            } else {
              window.CloseOwnerWindow(action);;
            }
          })
            
        } else {
          window.CloseOwnerWindow(action);
        }        
    }

</script>
</body>
</html>